home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
ZICXDTL.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-02
|
6KB
|
215 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: zn.cpp
// Title: Zinc Window Template
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
// This module contains code for the class ZI_CX_DETAIL.
//
// The code in this module may be written in C++ or C.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
//
//----------------------------------------------------------------------------
#include <zi.hpp>
#define USE_WIN_CX_DETAIL
#if OS_DOS
#include <zid.hpp>
#elif OS_WINDOWS
#include <ziw.hpp>
#else
#include <zio.hpp>
#endif
//----------------------------------------------------------------------------
// Description: Default constructor
// Parameters:
// Returns:
//----------------------------------------------------------------------------
FN_M ZI_CX_DETAIL::ZI_CX_DETAIL(RZ4_CX rcx)
: ZN_WINDOW("WIN_CX_DETAIL", ZN_LOAD_CENTER|ZN_LOAD_NO_SHOW)
{
ZI_CX_DETAIL::Initialize(CL_INIT_CLASS);
cx = rcx;
Setup();
}
//----------------------------------------------------------------------------
// Description: Destructor
// Parameters:
// Returns:
//----------------------------------------------------------------------------
FN_M ZI_CX_DETAIL::~ZI_CX_DETAIL()
{
ZI_CX_DETAIL::Destroy(FALSE);
Terminate();
}
//----------------------------------------------------------------------------
// Description: Destroy object. Free any resources used by object.
// Normally called by destructor.
// Should allow multiple calls from various classes.
// A class should almost always re-init its variables when
// it is destroyed to prevent accidents.
// Parameters: fDestroyAll Destroy parents also?
// Default is TRUE.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_M ZI_CX_DETAIL::Destroy(BOOL fDestroyAll)
{
ZI_CX_DETAIL::Initialize(CL_INIT_CLASS_VARS);
if (fDestroyAll) // Destroy parent.
ZI_CX_DETAIL_PARENT::Destroy(fDestroyAll);
return TRUE;
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
VOID FN_M ZI_CX_DETAIL::Format()
{
CHAR szFormat[160];
sprintf(szFormat, "%s, %s", cx.szCity, Z4_ST_FILE::Abbreviation(cx.state));
SetTitle(szFormat);
SetString(FID(STR_CITY), cx.szCity);
SetString(FID(STR_STATE), Z4_ST_FILE::Full(cx.state));
sprintf(szFormat, "%u", cx.cZip5);
SetString(FID(STR_ZIPS), szFormat);
if (cx.szPO[0])
{
SetString(FID(STR_NOTES),
"City name not valid for use on mail.");
sprintf(szFormat, "Preferred name is %s", cx.szPO);
SetString(FID(STR_PO), szFormat);
}
else
{
SetString(FID(STR_NOTES));
SetString(FID(STR_PO));
}
for (SIZET i = 0; i < cx.cZip5; ++i)
{
LONG lLow, lHigh; // Create list of ZIPs
CHAR szZip5[MAX_ZIP5+1];
strb2a(cx.abZip5[i], MAX_ZIP5_BCD, szZip5, MAX_ZIP5, TRUE);
szZip5[MAX_ZIP5] = '\0';
lLow = lHigh = atol(szZip5);
for (; i + 1 < cx.cZip5; ++i)
{
strb2a(cx.abZip5[i+1], MAX_ZIP5_BCD, szZip5, MAX_ZIP5, TRUE);
szZip5[MAX_ZIP5] = '\0';
LONG lZip = atol(szZip5);
if (lHigh + 1 == lZip)
lHigh = lZip;
else
break;
}
if (lLow == lHigh)
sprintf(szFormat, "%05ld", lLow);
else
sprintf(szFormat, "%05ld - %05ld", lLow, lHigh);
SetVtList(FID(LB_ZIP5), szFormat);
}
return ;
}
//----------------------------------------------------------------------------
// Description: Initialize object.
// Normally called by constructor.
// Should allow multiple calls from various classes.
// Parameters: sInit Initialization code. May be one of the following:
// CL_INIT_CLASS Reset class variables and
// and dynamic allocations for
// this class only.
// CL_INIT_CLASS_VARS Reset class variables for
// this class only.
// CL_INIT_VARS Reset class variables for
// this class only.
// CL_INIT_ALL Initialize class and all
// parent class, including
// dynamic memory allocation.
// Default is CL_INIT_ALL
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_M ZI_CX_DETAIL::Initialize(SHORT sInit)
{
if (sInit == CL_INIT_VARS || sInit == CL_INIT_ALL)
ZI_CX_DETAIL_PARENT::Initialize(sInit);
if (sInit == CL_INIT_CLASS_VARS || sInit == CL_INIT_VARS)
return TRUE;
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Event monitor function.
// Parameters: msg Event code
// pv1 Data pointer 1
// pv2 Data pointer 2
// Returns: Event code
//----------------------------------------------------------------------------
ZN_MSG FN_M ZI_CX_DETAIL::User(ZN_MSG msg, PVOID, PVOID)
{
switch (msg)
{
case ZN_MSG_INIT:
Format();
return msg;
case ZN_MSG_TERMINATE:
return msg;
}
if (IsError()) // Error condition
return msg;
switch (msg)
{
case BUTTON_OK:
Close();
break;
}
return msg;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------